  var mobileStatus;
  var createMulEle = function (parent, prop, ele, special) {
    if (Array.isArray(prop)) {
      parent.empty()
      // Array
      prop.forEach((child,index) => {
        let $element = $(ele);
        parent.append($element);
        $element.val(index);
        $element.text(child);
        if (special && index === special-1) {
          $element.key = special;
          $element.attr('selected', true);
        }
      })
    } else {
      // Object
      parent.empty()
      Object.keys(prop).forEach(key => {
        let $element = $(ele);
        parent.append($element);
        $element.val(key);
        $element.text(prop[key]);
        if ((special && special == prop[key]) || special && special == key) {
          $element.attr('selected', true);
        }
      })
    }
  }
  var ajaxURL = function (url) {
    return new Promise((resolve,reject) => {
      let callId = localStorage.getItem('callId');
      $.ajax({
        url: url,
        type: 'post',
        data: callId?{
          caseId: $('#caseId').val(),
          fieldType: $('#fieldType').val(),
          callId: callId
        }:{
          caseId: $('#caseId').val(),
          fieldType: $('#fieldType').val(),
        },
        success: res => {
          resolve(res);
        },
        error: rej => {
          reject(rej);
        }
      })
    })
  }
  // 详情获取初步案件信息接口
  function getCaseinfo () {
    if (localStorage.getItem('showButton')) {
      $('span[data-type="prev"]').css('display', 'none');
      $('span[data-type="next"]').css('display', 'none');
      localStorage.removeItem('showButton');
    }
    ajaxURL('/callinfo/caseinfo').then(res => {
      let {litigantName, pingyin_litigantName,sex, age, cardId, overdueMonth, mediationNum, debtTotal, mediateResult, repayStatus, showCardId,caseType,caseMainInfo} = res.data.header_case,
          {customLabel, customGrade, case_info, case_id, fieldType} = res.data,
          mediateResultSel = res.data.mediateResult;
      mobileStatus = res.data.mobileStatus;
      $('#user_name').text(litigantName); // 姓名
      $('#pinyin_user_name').text(pingyin_litigantName); // 拼音
      $('#user_sex').text(sex); // 性别
      $('#user_age').text(`${age}岁`); // 年龄
      $('#user_cardId').html(cardId); // 身份证号
      $('#user_cardId').attr('title', showCardId); // 身份证号
      $('#case_type').text(caseType); // 案件类型
      $('#case_main_info').text(caseMainInfo); // 案件主要信息
      $('#tjbd').text(debtTotal); //  调解标的
      $('#yqts').text(overdueMonth); // 逾期天数
      $('#result').text(mediateResult); // 结果状态
      $('#status').text(repayStatus); // 调解状态
      if(caseType == '诉保案件'){
        $('#case_type').css({'color':'#77c87a', 'background-color':'#ecf5ec'});
      }else if(caseType == '裁执案件'){
        $('#case_type').css({'color':'#FF5460', 'background-color':'#fff4f9'});
      }else{
        $('#case_type').css({'color':'#03A9F4', 'background-color':'#e2eef6'});
      }
      // // 用户标签
      // res.data.header_case.customLabel ++;
      // res.data.header_case.customGrade ++;
      createMulEle($('#user_label'), customLabel, '<option></option>', res.data.header_case.customLabel);
      // 用户等级
      createMulEle($('#user_leval'), customGrade, '<option></option>', res.data.header_case.customGrade);
      // 本次调解结果
      createMulEle($('#mediate_result'), mediateResultSel, '<option></option>', res.data.header_case.mediateResult);
      // 案件信息
      $('#list').html('');
      $('.detail_msg .left .tabs').children('.active').removeClass('active');
      $('.detail_msg .left .tabs span:first-child').addClass('active');
      $('.detail_msg .left .bottom .tab_content').children().css('display', 'none')
      $('#tab_mediate').css('display', 'inline-block');

      $('.detail_msg .right .tabs').children('.active').removeClass('active');
      $('.detail_msg .right .tabs span:first-child').addClass('active');
      $('.list_content').children().css('display', 'none')
      $('#list').css('display', 'inline-block');

      Object.keys(case_info).forEach(keyID => {
        let bod = '<div class="bod">';
        let listMsg = case_info[keyID],
            msgs = Object.keys(listMsg),
            $ele, $row=`<div>`, key;
        for(let i = 0;i<msgs.length-1;i++) {
          key = msgs[i];
          $row=`<div style="display:flex;">`;
          $row += `<p style="word-break:break-all;"><span>${key}:</span><span>${listMsg[key]}</span></p>`;
          i++;
          key = msgs[i];
          if (key && key!='') {
            $row += `<p style="word-break:break-all;"><span>${key}:</span><span>${listMsg[key]}</span></p></div>
            `;
          }

          bod+=$row;
          // $('#list').append($row);
        }
        bod+='</div>'
        $('#list').append(bod);
      });
      $('.new_detail').attr('name', case_id);
      $('.form_replay_caseId').val(case_id);
      $('.form_mediate_caseId').val(case_id);
      // mini dialog
      $('#mini_user_name').text(litigantName);
      $('#mini_user_num').text(mediationNum);
      $('#mini_user_crash').text(debtTotal);

      var currentTime = new Date();
      var formattedTime = currentTime.toLocaleString();
      if(mediateResult == '未沟通'){
        $("#desctextarea").val(formattedTime + '【无人接听】');
      }else{
        $("#desctextarea").val(formattedTime + '【'+mediateResult+'】');
      }

      getMobileMsg();
    });
  }
  getCaseinfo();
  // 获取电话接口
  var getMobileMsg = function () {
    $('#call_detail').html('');
    ajaxURL('/callinfo/getMobile').then(res => {
      res.data.forEach((every,index) => {
        let ele = `
          <div id=every${index} class='every'>
            <span id=telephone${index}>${every.enTelephone}</span>
            <span id=phone_source${index}>${every.mobileSource}</span>
            <select id=phone_select${index} class="form-control select-mini" data-select="phone-update" data-mobileId=${every.mobileId}>
            </select>
            <input class="dt_type" type="hidden" value=${every.mobileType} />
            <input class="dt_data" type="hidden" value=${every.businessData} />
            <input class="dt_id" type="hidden" value=${every.mobileId} />
            <img data-fn="callout" data-telephone=${every.telephone} data-mobileId=${every.mobileId} class='call_icon glyphicon glyphicon-earphone' src="/images/news/details/Frame.png" alt="" />
            <img id=tel_del${index} class="glyphicon glyphicon-trash" data-fn="delect-phone" src="/images/news/details/del.png" alt="" />
          </div>
        `;
        $('#call_detail').append(ele);
        every.mobileType===1 && $(`#tel_del${index}`).css('visibility', 'visible');
        mobileStatus && createMulEle($(`#phone_select${index}`), mobileStatus, '<option></option>', every.mobileStatus)
        // $('.phone-dropdown').html('
        // ')
      })
    });
  }
  // 补录号码
  function getNewMobile (newVal){
    $.ajax({
      url:"/callinfo/getMobile",
      method:"post",
      data:{
        caseId: $('[name="caseId"]').val(),
        callid: ''
      },
      success:function(res){
        if(res.code==200){
          let len = $('#call_detail').children().length;
          let ele = `
            <div id=every${len} class='every'>
              <span id=telephone${len}>${newVal}</span>
              <span id=phone_source${len}>补录号码</span>
              <select id=phone_select${len} class="form-control select-mini" data-select="phone-update" data-mobileId=4>
              </select>
              <img data-fn="callout" data-telephone=${newVal} data-mobileId=${res.data.caseId} class='call_icon glyphicon glyphicon-earphone' src="/images/news/details/Frame.png" alt="" />
              <img id=tel_del${len} class="glyphicon glyphicon-trash" data-fn="delect-phone" src="/images/news/details/del.png" alt="" />
            </div>
          `;
          $('#call_detail').append(ele);
          mobileStatus && createMulEle($(`#phone_select${len}`), mobileStatus, '<option></option>')
        }else{
          toastr.error(res.message);
        }
      },
      error: function(err){
        toastr.error('网络错误,请稍后重试');
      }
    })
  }

    /**
 * 指定日期增加n月
 * @param dateStr 指定日期
 * @param num 月
 * @param type 0:2023-01-30   1：2022-01-30 11:11:11
 * @returns {string}
 * @author: Leo
 */
    function commonAddMouth(dateStr, num, type , fixedday = 0) {
      var monthNum = 0;
      if (typeof num == "string") {
        monthNum = parseInt(num);
      } else {
        monthNum = num;
      }
      var date = new Date(dateStr);
      //获取原日
      if(fixedday){
        var day = fixedday;
      }else{
        var day = date.getDate();
      }
      //获取原月份
      var month = date.getMonth();
      //设置增加月份
      date.setMonth(date.getMonth() + monthNum * 1, 1);
      //获取增加的后的月份
      var Jmonth = date.getMonth() + 1;
      //获取增加的后的年份
      var Jyear = date.getFullYear();
      if (Jmonth == 4 || Jmonth == 6 || Jmonth == 9 || Jmonth == 11) {
        //小月
        if (day > 30) {
          day = 30;
        }
      } else if (Jmonth == 2) {
        //2月判断是否闰年
        if ((Jyear % 4 == 0 && Jyear % 100 != 0) || Jyear % 400 == 0) {
          if (day > 29) {
            day = 29;
          }
        }
        if (day > 28) {
          day = 28;
        }
      } else {
        //大月
        if (day > 31) {
          day = 31;
        }
      }
      var tHours = date.getHours();
      var tMinutes = date.getMinutes();
      var tSeconds = date.getSeconds();
      tHours = tHours < 10 ? "0" + tHours : tHours;
      tMinutes = tMinutes < 10 ? "0" + tMinutes : tMinutes;
      tSeconds = tSeconds < 10 ? "0" + tSeconds : tSeconds;
      Jmonth = doHandleMonth(Jmonth);
      day = doHandleMonth(day);
      if (type == "0") {
        return `${Jyear}-${Jmonth}-${day}`;
      }
      return `${Jyear}-${Jmonth}-${day} ${tHours}:${tMinutes}:${tSeconds}`;
    }

    /**
     *  日或月补0
     * @param month
     * @returns {string}
     */
    function doHandleMonth(month) {
      var m = month;
      if (month.toString().length == 1) {
        m = "0" + month;
      }
      return m;
    }

    $('body')
    .on('click', '#add_telphone', function () {
      // 添加电话
      $('.modal-content').css('display', 'inline-block');
    })
    .on('click', '#user_cardId', function () {
      // 添加电话
      alert($(this).attr('title'))
    })
    .on('click', '.close', function () {
      // 关闭添加电话
      $('.modal-content').css('display', 'none');
    })
    .on('click', '[data-fn="switch-page"]', function () {
      let self = $(this),
          type = self.data('type');
      let nextId = function () {
        $.ajax({
          url:"/callinfo/getNextId",
          method:"post",
          data:{
            caseId: $('[name="caseId"]').val(),
            direction: type,
            fieldType: $('#fieldType').val(),
          },
          success:function(res){
            if(res.code==200){
              let {caseId} = res.data;
              $('#caseId').val(caseId);
              getCaseinfo();
            }else{
              type=='next'?toastr.error('没有下一个了'):toastr.error('没有上一个了');
            }
            self.removeAttr('disabled',true);
          },
          error: function(err){
            toastr.error('网络错误,请稍后重试');
            self.removeAttr('disabled',true);
          }
        })
      }
      if (type === 'prev') {
        nextId();
      } else if (type === 'next') {
        nextId();
      } else if (type === 'minimize') {
        $('#details_page').css('display', 'none');
        $('.mini_container').css('display', 'inline-block');
      } else if (type === 'closes') {
        // 关闭详情页
        window.location.reload();
        // $('#details_page').css('display', 'none');
        // $('#details_page').html('');
      }
    })
    // .on('click','[data-hover="call"],.phone-dropdown',function(){
    //   $('.phone-dropdown').show();
    // })
    .on('click', '[data-dismiss="modal"]', function () {
      // 关闭添加电话
      $('.modal-content').css('display', 'none');
    })
    .on('click','[data-fn="add-phone"]',function(){
      let newVal = $('[data-value="new-phone"]').val();
      if(!newVal){
        toastr.error('请输入号码');
        return false;
      }
      if(!(/^1[3,4,5,6,7,8,9][0-9]{9}$/.test(newVal))){
        toastr.error("手机号码有误，请重新输入");
        return false;
      }
      $.ajax({
        url:"/callinfo/phoneAdd",
        method:"post",
        data:{
          caseId: $('[name="caseId"]').val(),
          telephone: newVal,
        },
        success:function(res){
          if(res.code==200){
            toastr.success(res.message);
            $('.modal-content').css('display', 'none');
            setTimeout(function(){
              getNewMobile(newVal)
            },1500)
          }else{
            toastr.error(res.message);
          }
        },
        error: function(err){
          toastr.error('网络错误,请稍后重试');
        }
      })
    })
    .on('click','[data-fn="delect-phone"]',function(){
      var that=$(this);
      $.confirm({
        title: '注意！',
        content: '确认删除该电话吗？',
        confirmButton: '确定',
        cancelButton: '取消',
        confirm: function(){
          let mobileId = that.parent().find('[data-select="phone-update"]').data('mobileid')
          $.ajax({
              url:"/callinfo/phoneDelete",
              method:"post",
              dataType: 'json',
              data:{
                'mobileId': mobileId
              },
              success:function(res){
                if(res.code==200){
                  toastr.success(res.message);
                  setTimeout(function(){
                    that.parent().css('display', 'none');
                  },1500)
                }else{
                  toastr.error(res.message);
                }
              },
              error: function(err){
                toastr.error('网络错误,请稍后重试');
              }
          })
        },
        cancel: function(){
          // alert('Canceled!')
        }
      });
    })
    .on('change','[data-select="phone-update"]',function(){
      var that=$(this);
      let mobileId = that.parent().find('[data-select="phone-update"]').data('mobileid');
      $.ajax({
        url:"/callinfo/phoneUpdate",
        method:"post",
        data:{
          mobileId: mobileId,
          mobileStatus: $(this).val(),
          mobileType: $(this).siblings('.dt_type').val()
        },
        success:function(res){
          if(res.code==200){
            toastr.success(res.message);
          }else{
            toastr.error(res.message);
          }
        },
        error: function(err){
          toastr.error('网络错误,请稍后重试');
        }
      })
    })
    .on('click','[data-fn="add-plan"]',function(){
      let tabContent= $('#tab_replay');
      let returnedMoney= tabContent.find('[name="returnedMoney"]').val();
      let repaymentPeriods= tabContent.find('[name="repaymentPeriods"]').val();
      let returnedDay= tabContent.find('[name="returnedDay"]').val();
      let firstReturnedMoney= tabContent.find('[name="firstReturnedMoney"]').val();
      let firstReturnedDay= tabContent.find('[name="firstReturnedDay"]').val();
      if(!returnedMoney){
        toastr.error('请输入还款总额');
        return false;
      }
      if(!repaymentPeriods){
        toastr.error('请输入还款期数');
        return false;
      }
      if(returnedDay == 0){
        toastr.error('请选择还款日');
        return false;
      }
      $('.plan-box').html('');
      var date = new Date();
      var nowYear = date.getFullYear();
      if(firstReturnedMoney){
        returnedMoney = returnedMoney - firstReturnedMoney
      }
      if(date.getDate() > returnedDay){
        var nowMonth = date.getMonth() + 1;
      }else{
        var nowMonth = date.getMonth();
      }
      for(var i=0;i<repaymentPeriods;i++){
        var newDate='';
        var newMoney=0;
        if(i==0){
          if(firstReturnedDay){
            newDate= firstReturnedDay;
          }else{
            newDate= commonAddMouth(nowYear+'-'+nowMonth+'-'+returnedDay,'1','0',returnedDay);
          }
        }else{
          var nextDate= $('.plan-box').children(":last-child").find('[type="date"]').val();
          newDate= commonAddMouth(nextDate,'1','0',returnedDay);
        }
        if(firstReturnedMoney>0){
          if(i==0){
            newMoney = (firstReturnedMoney*1).toFixed(2);;
          }else{
            newMoney = (returnedMoney/(repaymentPeriods-1)).toFixed(2);
          }
        }else{
          newMoney = (returnedMoney/repaymentPeriods).toFixed(2);
        }
        var hml= `
            <div class="ds-ac-jc plan-list" style="margin-bottom:10px;">
                <span class="col-sm-3">第${
            i+1
        }期</span>
                <div class="col-sm-4">
                    <input type="date" class="form-control" name="returnedDetail[${i}][returnedTime]" value="${newDate}">
                </div>
                <div class="col-sm-4">
                     <input type="text" class="form-control" name="returnedDetail[${i}][returnedMoney]" value="${newMoney}" placeholder="请输入金额">
                </div>
            </div>
        `;
        $('.plan-box').append(hml);
      }
      return false;
    })
    .on('click','[data-fn="save"]',function(){
      let activeType = $('.tab_his').children('.active').data('type');
      if (activeType.indexOf('replay')>-1) {
        // 保存添加还款记录
        $.ajax({
          url:"/callinfo/addReturnedMoneyPlan",
          method:"post",
          data: $('.form_replay').serialize(),
          success:function(res){
            if(res.code==200){
              toastr.success(res.message);
            }else{
              toastr.error(res.message);
            }
          },
          error: function(err){
            toastr.error('网络错误,请稍后重试');
          }
        })
      } else {
        // 保存添加调解记录
        var _this=$(this);
        if(_this.attr('disabled')) return;
        _this.attr('disabled',true);
        $.ajax({
          url:"/callinfo/addMediationLog",
          method:"post",
          data: $('.form_mediate').serialize(),
          success:function(res){
            if(res.code==200){
              toastr.success('保存成功');
              _this.next().click();
            }else{
              toastr.error(res.message);
            }
            _this.removeAttr('disabled',true);
          },
          error: function(err){
            toastr.error('网络错误,请稍后重试');
            _this.removeAttr('disabled',true);
          }
        })
        return false;
      }
    })
    .on('click','[data-fn="saveAdvance"]',function(){
      // 添加投诉记录
      $.ajax({
        url:"/callInfo/saveSuggestion",
        method:"post",
        data: {
          desc: $('#advanceContent').val(),
          callId: localStorage.getItem('callId'),
          case_id: $('.form_mediate_caseId').val()
        },
        success:function(res){
          if(res.code==200){
            toastr.success('保存成功');
          }else{
            toastr.error(res.message);
          }
        },
        error: function(err){
          toastr.error('网络错误,请稍后重试');
        }
      })
    })
    .on('click','[data-fn="cancel"]',function(){
      let activeType = $('.tab_his').children('.active').data('type');
      if (activeType.indexOf('replay')>-1) {
        // 取消添加还款记录
        $('.plan-box').html('');
      } else {
        // 取消添加调解记录
      }
    })
    .on('click', '.bottom .tabs span', function() {
      // 添加记录
      let self = $(this),
          type = self.data('type');
      self.siblings().removeClass('active');
      self.attr('class', 'active');
      $('.tab_content').children().css('display', 'none');
      $(`#${type}`).css('display', 'block');
    })
    .on('click','.switch-item',function(){
      $('.list_content').children().css('display', 'none');
      let type=$(this).data('type');
      if(type=='mediationLog'){
        $('#getMediationLog').css('display', 'inline-block');
        $.ajax({
          url:"/callinfo/getMediationLog",
          method:"post",
          data:{
            caseId: $('[name="caseId"]').val(),
          },
          success:function(res){
            if(res.code==200){
              if(res.data.length){
                var hml='';
                $.each(res.data,function(index,val){
                    hml+=`
                      <li class="sv-timeline-item">
                        <div class="step">
                          <div class="sv-timeline-item__node sv-timeline-item__node--normal sv-timeline-item__node--">
                            <div></div>
                          </div>
                          <div class="sv-timeline-item__tail"></div>
                        </div>
                        <div class="sv-timeline-item__wrapper">
                          <div class="sv-timeline-item__timestamp is-bottom">${val.addTime}</div>
                          <div class="sv-timeline-item__content">
                            <div style="color:#666">${val.mediatorName}&nbsp;${val.type}&nbsp;${val.mobile}&nbsp;【${val.mediateResult}】【${val.mediateType}】</div>
                      `;
                    if(val.nextTime){
                      hml+=`<div>联系计划：${val.nextTime}</div>`;
                    }
                    hml+=`<div>${val.desc} </div>`;
                    if(val.fileName){
                      hml+=`<div><audio controls="controls" src="${val.fileName}" style="width: 220px;height: 36px;margin-top: 10px;"></audio></div>`;
                    }
                    ` </div>
                        </div>
                      </li>
                    `;
                  })
                  $('.getMediationLog').html(hml);
                }else{
                  $('.getMediationLog').html('<div class="show-table table_connect_noData" style="height: 100%;text-align:center;display:flex;flex-direction:column;justify-content:center;align-items:center;"><p style="margin-top:5%;"><img src="/images/news/index/noData.png" alt=""></p><p style="padding-top:10px;font-size: 14px;color: #86909C;">暂无数据</p></div>');
                }
              }else{
                toastr.error(res.message);
              }
          },
          error: function(err){
            toastr.error('网络错误,请稍后重试');
          }
        })
      }else if(type=='sMSLog'){
        $('#getSMSLog').css('display', 'inline-block');
        $.ajax({
          url:"/callinfo/getSMSLog",
          method:"post",
          data:{
            caseId: $('[name="caseId"]').val(),
          },
          success:function(res){
            if(res.code==200){
              if(res.data.length){
                var hml='';
                $.each(res.data,function(index,val){
                    hml+=`
                      <li class="sv-timeline-item">
                        <div class="step">
                          <div class="sv-timeline-item__node sv-timeline-item__node--normal sv-timeline-item__node--">
                            <div></div>
                          </div>
                          <div class="sv-timeline-item__tail"></div>
                        </div>
                        <div class="sv-timeline-item__wrapper">
                          <div class="sv-timeline-item__timestamp is-bottom">${val.sendTime }</div>
                          <div class="sv-timeline-item__content">
                            <div style="color:#666">${val.mediator}&nbsp;${val.mobile}【${val.scene}】${val.sendStatus}</div>
                            <div>${val.content} </div>
                          </div>
                        </div>
                      </li>
                    `;
                })
                $('.getSMSLog').html(hml);
              }else{
                $('.getSMSLog').html('<div class="show-table table_connect_noData" style="height: 100%;text-align:center;display:flex;flex-direction:column;justify-content:center;align-items:center;"><p style="margin-top:5%;"><img src="/images/news/index/noData.png" alt=""></p><p style="padding-top:10px;font-size: 14px;color: #86909C;">暂无数据</p></div>');
              }
            }else{
              toastr.error(res.message);
            }
          },
          error: function(err){
            toastr.error('网络错误,请稍后重试');
          }
        })
      }else if(type=='operateLog'){
        $('#getOperateLog').css('display', 'inline-block');
        $.ajax({
          url:"/callinfo/getOperateLog",
          method:"post",
          data:{
            caseId: $('[name="caseId"]').val(),
          },
          success:function(res){
            if(res.code==200){
              if(res.data.length){
                var hml='';
                $.each(res.data,function(index,val){
                  hml+=`
                    <li class="sv-timeline-item">
                      <div class="step">
                        <div class="sv-timeline-item__node sv-timeline-item__node--normal sv-timeline-item__node--">
                          <div></div>
                        </div>
                        <div class="sv-timeline-item__tail"></div>
                      </div>
                      <div class="sv-timeline-item__wrapper">
                        <div class="sv-timeline-item__timestamp is-bottom">${val.createTime }</div>
                        <div class="sv-timeline-item__content">
                          <div style="color:#666">${val.operationName}&nbsp;${val.operationContent}</div>
                          <div>${val.remark} </div>
                        </div>
                      </div>
                    </li>
                  `;
                })
                $('.getOperateLog').html(hml);
              }else{
                $('.getOperateLog').html('<div class="show-table table_connect_noData" style="height: 100%;text-align:center;display:flex;flex-direction:column;justify-content:center;align-items:center;"><p style="margin-top:5%;"><img src="/images/news/index/noData.png" alt=""></p><p style="padding-top:10px;font-size: 14px;color: #86909C;">暂无数据</p></div>');
              }
            }else{
              toastr.error(res.message);
            }
          },
          error: function(err){
            toastr.error('网络错误,请稍后重试');
          }
        })
      }else if(type=='returnedPlan'){
        $('#getReturnedPlan').css('display', 'inline-block');
        $.ajax({
          url:"/callinfo/getReturnedPlan",
          method:"post",
          data:{
            caseId: $('[name="caseId"]').val(),
          },
          success:function(res){
            if(res.code==200){
              if (res.data.length==0) {
                $('#getReturnedPlan').html('<div class="show-table table_connect_noData" style="height: 100%;text-align:center;display:flex;flex-direction:column;justify-content:center;align-items:center;"><p style="margin-top:5%;"><img src="/images/news/index/noData.png" alt=""></p><p style="padding-top:10px;font-size: 14px;color: #86909C;">暂无数据</p></div>');
                return false;
              }
              //if(planData && planData.length){
              if(res.data){
              var hml='';
                $.each(res.data,function(caseid,val){
                  let planData = val;
                  hml+=`
                    <div style="height: auto;display: flex;flex-direction: column;box-sizing: border-box;margin: 0 auto;overflow: hidden;">
                      <div style="display: flex;flex:1;border-bottom: 1px solid #EDEDED;border-left: 1px solid #EDEDED;box-sizing:border-box;height:34px;line-height:34px;">
                        <p style="margin-left:30px;width:50%;border-right:text-align:center;">案件号：${caseid}</p>
                      </div>
                    </div>
                      `;
                  $.each(planData,function(index,val){
                    hml+=`
                    <div style="height: auto;display: flex;flex-direction: column;box-sizing: border-box;margin: 0 auto;overflow: hidden;">
                      <div style="display: flex;flex:1;border-bottom: 1px solid #EDEDED;border-left: 1px solid #EDEDED;box-sizing:border-box;height:34px;line-height:34px;">
                        <p style="width:25%;border-right:1px solid #EDEDED;text-align:center;">${val.term}</p>
                        <p style="width:25%;border-right:1px solid #EDEDED;text-align:center;">${val.repaymentDate}</p>
                        <p style="width:25%;border-right:1px solid #EDEDED;text-align:center;">${val.repayAmount}</p>
                        <p style="width:25%;border-right:1px solid #EDEDED;text-align:center;">${val.status}</p>
                      </div>
                    </div>
                      `;
                  })
                })
                $('#getReturnedPlan').html(hml);
              }else{
                $('#getReturnedPlan').html('<div class="show-table table_connect_noData" style="height: 100%;text-align:center;display:flex;flex-direction:column;justify-content:center;align-items:center;"><p style="margin-top:5%;"><img src="/images/news/index/noData.png" alt=""></p><p style="padding-top:10px;font-size: 14px;color: #86909C;">暂无数据</p></div>');
              }
            } else{
              toastr.error(res.message);
            }
          },
          error: function(err){
            toastr.error('网络错误,请稍后重试');
          }
        })
      } else if (type==='msgLog') {
        $('#list').css('display', 'inline-block');
      }
    })
    .on('change','[data-select="custom-select"]',function(){
      $.ajax({
        url:"/callinfo/updateAttribute",
        method:"post",
        data:{
          caseId: $('.new_detail').attr('name'),
          attribute: $(this).attr('name'),
          attributeVal: $(this).val(),
        },
        success:function(res){
          if(res.code==200){
            toastr.success(res.message);
          }else{
            toastr.error(res.message);
          }
        },
        error: function(err){
          toastr.error('网络错误,请稍后重试');
        }
      })
     })
     //mouseenter
    .on('click', '#close_mini', function() {
      // 关闭mini窗口
      $('#details_page').css('display', 'none');
      $('#details_page').html('');
      $('.mini_container').css('display', 'none');
    })
    .on('click', '#unfold_mini', function() {
      // 展开弹窗内容
      $('#details_page').css('display', 'inline-block');
      $('.detail_mask').css('display', 'inline-block');
      $('.new_detail').css('display', 'inline-block');
      $('.modal-content').css('display', 'none');
      $('.mini_container').css('display', 'none');
    })
